package com.example.sofclick;

import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;

public class HorizontalScrollViewSofia extends HorizontalScrollView{

	public HorizontalScrollViewSofia(Context context) {
		super(context);
	}
	
	public HorizontalScrollViewSofia(Context context, AttributeSet attrs){
		super(context, attrs);
	}
	
	public HorizontalScrollViewSofia(Context context, AttributeSet attrs, int defStyle){
		super(context,attrs, defStyle);
	}
	
	public void onScrollChanged(int l, int t, int oldl, int oldt){
		super.onScrollChanged(l, t, oldl, oldt);
		int idView = this.getId();
		int idBody = R.id.amortization_scroll_hor;
		int idup = R.id.col_names_scroll;
		Resources res=getResources();
		if(idView==idBody){
			
			
			ScrollViewSofia parent1 = (ScrollViewSofia)this.getParent();
			LinearLayout parent2 = (LinearLayout)parent1.getParent();
			LinearLayout parent3 = (LinearLayout)parent2.getParent();
			LinearLayout child1 =(LinearLayout)parent3.getChildAt(0);
			HorizontalScrollViewSofia child2 =(HorizontalScrollViewSofia)child1.getChildAt(1);//0 = texto compensacion
			child2.scrollTo(l,t);
		}
		if(idView==idup){
			LinearLayout parent = (LinearLayout)this.getParent();
			LinearLayout parent2 = (LinearLayout)parent.getParent();
			LinearLayout child = (LinearLayout)parent2.getChildAt(1);
			ScrollViewSofia child2 = (ScrollViewSofia)child.getChildAt(1);
			HorizontalScrollViewSofia child3 = (HorizontalScrollViewSofia)child2.getChildAt(0);
			child3.scrollTo(l,t);
		}		
	}
    
	/**
	 * @param args
	 */


}
